<%-- 
    Document   : w_product
    Created on : Sep 22, 2013, 3:11:55 PM
    Author     : Trang
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="model.Role"%>
<%@page import="model.Staff"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="http://displaytag.sf.net" prefix="display" %>


<!DOCTYPE html>
<%
    Staff staff = (Staff) session.getAttribute("staff");

    if (staff == null) {
        response.sendRedirect(request.getContextPath() + "/Administration");
    }  else {
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Inventory Management</title>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

        <link href="<%= request.getContextPath()%>/css/style_for_page.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_menu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_warehousing.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_addtion.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/adMenu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/tHeaderFooter.css" rel="stylesheet" type="text/css"/>
    </head>
    <body style="background-color: lightsteelblue;">
        <% int i = 0;%>
        <div class="headerbg">
            <div class="header"> 
                <%@include file="/include/mHeader.jsp" %>
            </div>
            <div class="adContent">
                <div class="adMenu">
                    <%@include file="/include/mMenu.jsp" %>
                </div>
            </div>
        </div>
        <div class="contentbg">
            <div class="content">
                <div style="width: 1024px; color: white; background-color: #610B0B; float:left;margin:auto;">
                    <h3 style="margin-left: 10px;">Inventory</h3>
                </div>
                <div id="errorMessage" style="border-bottom: 1px #610B0B dashed; ">
                    <div id="sl12">
                        <img src="<%= request.getContextPath()%>/css/create.png" style="height: 40px; width: 40px;"/>
                    </div>
                    <div id="sl12">
                        <s:form action="search" namespace="/Administration/Inventory">     
                            <s:textfield label="Input keyword to search" cssStyle="margin-left:-12px;" name="keyword" size="30" theme="simple" />
                            <s:submit value="Search" cssStyle="width: 100px; margin-left: 12px; background-color: gray;" theme="simple" title="Quick Search"/>
                        </s:form>
                    </div>
                    <div id="sl12">
                        <s:actionerror />
                    </div>
                    <s:form cssStyle="float:left" action="sort-inventory" namespace="/Administration/Inventory" theme="simple">
                        <div id="sl12">
                            <p style="margin-left: -12px;"><b>Sort by: </b><s:select name="sort" cssStyle="width: 200px" list="sorts" /></p>
                        </div>     
                        <div id="sl12">
                            <s:submit  value="Sort" cssStyle="width: 100px; background-color: gray;" theme="simple" title="Sort Inventory"/> 
                        </div>
                    </s:form>    
                </div>         
                <div class="content2">  
                    <%
                        Integer product = (Integer) session.getAttribute("product");
                        int[] idProduct = (int[])session.getAttribute("idProduct");
                        if (product == 1) {   
                    %>
                    <div class="datagrid2">                  
                        <display:table id="data" export = "true" name="products" pagesize="8" requestURI="inventory">    
                            <%i++;%>
                            <display:column title="No" media="html" group="1" >
                                <p><%out.print(i);%></p>
                            </display:column>               
                            <display:column property="code" title="Product Code" sortable="true"/>         
                            <display:column property="name" title="Product Name" sortable="true" />
                            <display:column property="brand" title="Brand" sortable="true"/>
                            <display:column property="category.name" title="Category" maxWords="10" sortable="true" />
                            <display:column property="details" title="Details" maxWords="5" sortable="true" />
                            <display:column property="unitPrice" title="Unit Price ($)" sortable="true" />
                            <display:column style="color: red;" property="stockQuantity" title="Stock Quan" sortable="true" /> 
                            <display:column media="html">
                                <a href="<%= request.getContextPath()%>/Administration/Request/request-receipt-page/<%=idProduct[i-1]%>" title="<s:property value='description'/>">
                                    Request Receipt
                                </a>   
                            </display:column> 
                        </display:table>
                    </div>
                    <% }
                    else if(product==2)
                    {
                    %>
                    <div class="datagrid2">                  
                        <display:table id="data" export = "true" name="products" pagesize="8" requestURI="sort-inventory">    
                            <%i++;%>
                            <display:column title="No" media="html" group="1" >
                                <p><%out.print(i);%></p>
                            </display:column>               
                            <display:column property="code" title="Product Code" sortable="true"/>         
                            <display:column property="name" title="Product Name" sortable="true" />
                            <display:column property="brand" title="Brand" sortable="true"/>
                            <display:column property="category.name" title="Category" maxWords="10" sortable="true" />
                            <display:column property="details" title="Details" maxWords="10" sortable="true" />
                            <display:column property="unitPrice" title="Unit Price" sortable="true" />
                            <display:column property="stockQuantity" title="Stock Quantity" sortable="true" /> 
                            <display:column media="html">
                                <a href="<%= request.getContextPath()%>/Administration/Request/request-receipt-page/<%=idProduct[i-1]%>" title="<s:property value='description'/>">
                                    Request Receipt
                                </a>   
                            </display:column> 
                        </display:table>
                    </div>
                    <%
                    } else
                    {
                    %>
                    <div class="datagrid2">                  
                        <display:table id="data" export = "true" name="products" pagesize="8" requestURI="search">    
                            <%i++;%>
                            <display:column title="No" media="html" group="1" >
                                <p><%out.print(i);%></p>
                            </display:column>               
                            <display:column property="code" title="Product Code" />         
                            <display:column property="name" title="Product Name" />
                            <display:column property="brand" title="Brand" />
                            <display:column property="category.name" title="Category" maxWords="10" />
                            <display:column property="details" title="Details" maxWords="10" />
                            <display:column property="unitPrice" title="Unit Price" />
                            <display:column property="stockQuantity" title="Stock Quantity" /> 
                            <display:column media="html">
                                <a href="<%= request.getContextPath()%>/Administration/Request/request-receipt-page/<%=idProduct[i-1]%>" title="<s:property value='description'/>">
                                    Request Receipt
                                </a>   
                            </display:column> 
                        </display:table>
                    </div>
                    <%}%>
                </div>   
            </div>
        </div>
    <footer>
        <div id="footer">
            <%@include file="/include/iFooter.jsp" %>
        </div>    
    </footer>
</body>
</html>
<%
    }
%>